package com.xique.door.service.impl;

import java.util.ArrayList;
import java.util.List;

import cn.hutool.core.collection.CollectionUtil;
import com.xique.common.core.text.Convert;
import com.xique.common.core.utils.DateUtils;
import com.xique.door.bean.domain.DCardHouse;
import com.xique.door.mapper.DCardHouseMapper;
import com.xique.door.service.IDCardHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * cardHouseService业务层处理
 *
 * @author caogq
 * @date 2022-03-08
 */
@Service
public class DCardHouseServiceImpl implements IDCardHouseService
{
    @Autowired
    private DCardHouseMapper dCardHouseMapper;

    /**
     * 查询cardHouse
     *
     * @param id cardHouseID
     * @return cardHouse
     */
    @Override
    public DCardHouse selectDCardHouseById(Long id)
    {
        return dCardHouseMapper.selectDCardHouseById(id);
    }

    /**
     * 查询cardHouse列表
     *
     * @param dCardHouse cardHouse
     * @return cardHouse
     */
    @Override
    public List<DCardHouse> selectDCardHouseList(DCardHouse dCardHouse)
    {
        return dCardHouseMapper.selectDCardHouseList(dCardHouse);
    }

    /**
     * 新增cardHouse
     *
     * @param dCardHouse cardHouse
     * @return 结果
     */
    @Override
    public int insertDCardHouse(DCardHouse dCardHouse)
    {
        dCardHouse.setCreateTime(DateUtils.getNowDate());
        return dCardHouseMapper.insertDCardHouse(dCardHouse);
    }

    /**
     * 修改cardHouse
     *
     * @param dCardHouse cardHouse
     * @return 结果
     */
    @Override
    public int updateDCardHouse(DCardHouse dCardHouse)
    {
        dCardHouse.setUpdateTime(DateUtils.getNowDate());
        return dCardHouseMapper.updateDCardHouse(dCardHouse);
    }

    /**
     * 删除cardHouse对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteDCardHouseByIds(String ids)
    {
        return dCardHouseMapper.deleteDCardHouseByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除cardHouse信息
     *
     * @param id cardHouseID
     * @return 结果
     */
    @Override
    public int deleteDCardHouseById(Long id)
    {
        return dCardHouseMapper.deleteDCardHouseById(id);
    }

    @Override
    public int batchInsertDCardHouse(List<DCardHouse> dCardHouses) {

        return dCardHouseMapper.batchInsertDCardHouse(dCardHouses);
    }

    @Override
    public List<DCardHouse> selectCardHouseListByHouseIds(List<Long> houseIds) {
        if (CollectionUtil.isEmpty(houseIds)) {
            return new ArrayList<>();
        }
        return dCardHouseMapper.selectCardHouseListByHouseIds(houseIds);
    }
}
